﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

using WatiNSahi;


using WatiN.Core;
using WatiN.Core.Native;
using WatiN.Core.Logging;
using WatiN.Core.UtilityClasses;
using WatiN.Core.Properties;
using WatiN.Core.Native.Windows;
using WatiN.Core.DialogHandlers;

using WatiNSahi.Extensions;
using System.Collections.Specialized;

namespace WatiNSahiTester
{
    class WatiNSahiTester
    {
        [STAThread]
        static void Main(string[] args)
        {

            //new WatiNSahiGoogleTests()._find_in_google();

            //new WatiNSahiLogTest()._log_test();



            //Thread th1 = new Thread(() => new WatiNSahiGoogleTests()._find_in_google());
            //th1.SetApartmentState(ApartmentState.STA);
            //th1.Start();
            


            //new WatiNSahiFunctionTests()._login_test_demo_web_server();

            //th1.Join();


            //Thread th1 = new Thread(() => new WatiNSahiExtensionTests()._test_extension());
            //th1.SetApartmentState(ApartmentState.STA);
            //th1.Start();
            //th1.Join();


            //new WatiNSahiExtensionTests()._test_extension();
            //foreach (var item in new string[]{ "One", "Two", "three"})
            //{
            //    Console.WriteLine(string.Format("Test number :: '{0}' ",item.ToString()));
            //    new WatiNSahiFireFoxTests()._test_firefox_google();
            //}
            //new WatiNSahiFireFoxTests()._test_enovia_login_logout();
            new WatiNSahiFireFoxTests()._test_firefox_google();
            //new WatiNSahiGoogleTests()._find_in_google();
            //new WatiNSahiExtensionTests()._test_extension();
            
            JSEventCreator evt = new JSEventCreator("test", null);
            NameValueCollection eventProp = new NameValueCollection();
            eventProp.Add("clientX", "12");
            string scriptCode = evt.CreateMouseEventCommand("mouseover",eventProp);

        }

        public void Should_create_mouse_event_with_params_set()
        {
            // GIVEN
            var eventParams = new NameValueCollection
                {
                    {"type", "type"},
                    {"bubbles", "bubbles"},
                    {"cancelable", "cancelable"},
                    {"windowObject", "windowObject"},
                    {"detail", "detail"},
                    {"screenX", "screenX"},
                    {"screenY", "screenY"},
                    {"clientX", "clientX"},
                    {"clientY", "clientY"},
                    {"ctrlKey", "ctrlKey"},
                    {"altKey", "altKey"},
                    {"shiftKey", "shiftKey"},
                    {"metaKey", "metaKey"},
                    {"button", "button"},
                    {"relatedTarget", "relatedTarget"}
                };

            //var creator = new JSEventCreator("test", new ClientPortBase(null));

            //// WHEN
            //var command = creator.CreateMouseEventCommand("mousedown", eventParams);

            //// THEN
            //Assert.That(command, Is.Not.Null, "Expected code");
            //Assert.That(command, Is.EqualTo("var event = test.ownerDocument.createEvent(\"MouseEvents\");event.initMouseEvent('mousedown',bubbles,cancelable,windowObject,detail,screenX,screenY,clientX,clientY,ctrlKey,altKey,shiftKey,metaKey,button,relatedTarget);"), "Unexpected method signature");
        }
    }
}
